package com.amigo.online.amigo.online.provider.mimc.controller

import com.amigo.online.amigo.online.provider.mimc.config.Constants
import com.amigo.online.amigo.online.provider.mimc.config.POJO
import com.amigo.online.amigo.online.provider.mimc.entity.MIMCTokenResponse
import com.amigo.online.amigo.online.provider.mimc.utils.HttpUtil
import com.amigo.online.common.base.controller.BaseController
import com.amigo.online.common.core.response.Response
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/mimc")
class MIMCTokenController : BaseController() {

    @GetMapping("/token")
    fun token(@RequestParam userId: String): ResponseEntity<Response> {
        val json = Constants.getBaseRequest()
        json["appAccount"] = userId
        return success(HttpUtil.post(Constants.MIMC_TOKEN, json).POJO<MIMCTokenResponse>().data)
    }
}